package com.lifeng.patterns.chainofResponsibility;

/**
 * @description:
 * @author: lifeng
 * @create: 2020/9/10 16:51
 * 抽象的审批处理节点
 */
public abstract class AbstractApprovaHandler {
    public AbstractApprovaHandler(AbstractApprovaHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public AbstractApprovaHandler() {
    }

    /**
     * 下一个处理节点
     * */
    protected AbstractApprovaHandler nextHandler;

    public Boolean submit(Integer fees){
        //审批结果
        Boolean approvaResult = doHandler(fees);
        if(approvaResult){
            //下一个处理节点不为空,交给下一个人处理
            if(nextHandler!=null){
                return nextHandler.submit(fees);
            }
        }
        return approvaResult;
    }

    protected abstract Boolean doHandler(Integer fees);
}
